<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<html>
	<head>
		<title>发布业务流程</title>
		<%@ include file="/common/meta.jsp"%>
		<%@ include file="/common/jquery-ui-inc.jsp"%>
		<script>
			$(function() {
				$("#uploadForm").form({
				onSubmit:function(){
		    		if($("#upload").val()==""){
		    			$.messager.alert('提示','请选择需要上传的流程文件','warning');
		    			return false;
		    		}
		    		
		    		if($("#imgUpload").val()==""){
		    			$.messager.alert('提示','请选择需要上传的流程图片','warning');
		    			return false;
		    		}
		    		
		    		if(!checkFiles($("#upload").val(),'xml')){
		    			
		    			$.messager.alert('提示','流程定义文件格式有误','warning');
		    			return false;
		    		}
		    		
		    		if(!checkFiles($("#imgUpload").val(),'pic')){
		    			$.messager.alert('提示','流程图文件格式有误','warning');
		    			return false;
		    		}
		    		
		    	return true;
		   		 },
					url:"${ctx}/flow/core/flow-deploy!edit.action?deploymentId=${deploymentId}&deployId=${deployId}",
					success:function(data){
						var d = $.parseJSON(data);
						$.messager.alert("提示",d.msg);
						
						if(d.flag == 'T'){
							parent.closeBusProcessWin();
						}
						
					}
				})
			});
			
		
			
		function checkFiles(str,file){
		   var strRegex=null;
		   if("pic"==file){//对图片格式的验证
		   	 strRegex = "(.jpg|.png|.gif)$"; 
		   }else if("xml"==file){
		     strRegex = "(.xml)$"; 
		   }
   		   
	       var re=new RegExp(strRegex);
	       if (re.test(str.toLowerCase())){
	           return true;
	       }
	       else{
	           return false;
	       }
   		}
			
			
			
	</script>
	</head>

	<body>
			<form id="uploadForm"  name="uploadForm" action="" method="POST" enctype="multipart/form-data">
				<table class="datagrid-body">
					<tr><td colspan="2"><span style="font-weight:bold;color:red;">更改的文件</span></td></tr>
					<tr>
						<td>流程定义文件<span style="color:red;">*</span>：</td>
						<td><input name="upload" id="upload" class="easyui-validatebox" required="true" type=file size=20></td>
					</tr>
					<tr>
						<td>流程图片<span style="color:red;">*</span>：</td>
						<td><input name="imgUpload" id="imgUpload" class="easyui-validatebox" required="true" type=file size=20></td>
					</tr>
					
					<tr>
					<table id="lockList"></table>
					<td><input type="submit" value="提交"/>
					</td>
					<td><input type="reset" value="重置"/></td>
					</tr>
				</table>
			</form>
	</body>
</html>